home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 4 April 1997
- //
- // Description:
- // This is a helper script to perform the "diskCache -append" command
- // using the corresponding option box values.
- //
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- // Time range
- //
- if($forceFactorySettings || !`optionVar -exists appendDiskCacheTimeRange`)
- {
- optionVar -intValue appendDiskCacheTimeRange 2;
- }
-
- // startTime
- //
- if ($forceFactorySettings || !`optionVar -exists appendDiskCacheStartTime`)
- {
- optionVar -floatValue appendDiskCacheStartTime 1.0;
- }
-
- // endTime
- //
- if ($forceFactorySettings || !`optionVar -exists appendDiskCacheEndTime`) {
- optionVar -floatValue appendDiskCacheEndTime 10.0;
- }
-
- // sampling mode
- //
- if ($forceFactorySettings || !`optionVar -exists appendDiskCacheSampling`)
- {
- optionVar -intValue appendDiskCacheSampling 1;
- }
-
- // sampling rate
- //
- if( $forceFactorySettings
- ||! `optionVar -exists appendDiskCacheSamplingRate` )
- {
- optionVar -intValue appendDiskCacheSamplingRate 1;
- }
- }
-
-
- //
- // Procedure Name:
- // appendDiskCacheEnabling
- //
- // Description:
- // Set the enable state of start and end time fields.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that object names of the fields can be
- // successfully resolved.
- //
- // state - Enable state of the fields.
- //
- // Return Value:
- // None.
- //
- global proc appendDiskCacheEnabling()
- {
- int $startEnd = ( `radioButtonGrp -q -sl appendDiskCacheTimeRange4` == 1 );
- floatFieldGrp -edit -enable $startEnd appendDiskCacheStartEndTime;
- }
-
- //
- // Procedure Name:
- // appendDiskCacheSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc appendDiskCacheSetup(string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
-
- setParent $parent;
-
- // Range start
- //
- int $rangeStart = `optionVar -query appendDiskCacheTimeRange`;
- eval( "radioButtonGrp -e -select 1 appendDiskCacheTimeRange"+$rangeStart);
-
- // Start/End
- //
- float $startTime = `optionVar -query appendDiskCacheStartTime`;
- float $endTime = `optionVar -query appendDiskCacheEndTime`;
- floatFieldGrp -edit
- -value1 $startTime
- -value2 $endTime
- appendDiskCacheStartEndTime;
-
- // -increment
- //
- int $sampling = `optionVar -q appendDiskCacheSampling` ;
- radioButtonGrp -edit -sl $sampling appendDiskCacheSampling;
-
- int $samplingRate = `optionVar -q appendDiskCacheSamplingRate` ;
- intSliderGrp -edit -v $samplingRate appendDiskCacheSamplingRate;
-
- appendDiskCacheEnabling();
- }
-
- //
- // Procedure Name:
- // appendDiskCacheCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc appendDiskCacheCallback(string $parent, int $doIt)
- {
- setParent $parent;
-
- // start/end range
- //
- int $timeRangeMode = 2;
-
- if( `radioButtonGrp -q -sl appendDiskCacheTimeRange1` ) {
- $timeRangeMode = 1;
- } else if( `radioButtonGrp -q -sl appendDiskCacheTimeRange2` ) {
- $timeRangeMode = 2;
- } else if( `radioButtonGrp -q -sl appendDiskCacheTimeRange3` ) {
- $timeRangeMode = 3;
- } else if( `radioButtonGrp -q -sl appendDiskCacheTimeRange4` ) {
- $timeRangeMode = 4;
- }
-
- optionVar -intValue appendDiskCacheTimeRange $timeRangeMode;
-
- // start/end Time
- //
- optionVar -floatValue appendDiskCacheStartTime
- `floatFieldGrp -query -value1 appendDiskCacheStartEndTime`;
- optionVar -floatValue appendDiskCacheEndTime
- `floatFieldGrp -query -value2 appendDiskCacheStartEndTime`;
-
- // sampling mode
- //
- optionVar -intValue appendDiskCacheSampling
- `radioButtonGrp -query -sl appendDiskCacheSampling`;
-
- // sampling rate
- //
- optionVar -intValue appendDiskCacheSamplingRate
- `intSliderGrp -query -v appendDiskCacheSamplingRate`;
-
- if( $doIt ) {
- performAppendDiskCache 0;
- }
- }
-
- //
- // Procedure Name:
- // appendDiskCacheOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc appendDiskCacheOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "appendDiskCache";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- string $layout = getOptionBox();
- setParent $layout;
-
- setUITemplate -pushTemplate DefaultTemplate;
- tabLayout -tv false -scr true;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- radioButtonGrp
- -label "Append Time Range" -nrb 1
- -l1 "Current Time"
- -cc "appendDiskCacheEnabling"
- appendDiskCacheTimeRange1;
-
- radioButtonGrp
- -label "" -nrb 1
- -scl appendDiskCacheTimeRange1
- -l1 "Current Time to Time Slider End"
- -cc "appendDiskCacheEnabling"
- appendDiskCacheTimeRange2;
-
- radioButtonGrp
- -label "" -nrb 1
- -scl appendDiskCacheTimeRange1
- -l1 "Time Slider"
- -cc "appendDiskCacheEnabling"
- appendDiskCacheTimeRange3;
-
- radioButtonGrp
- -label "" -nrb 1
- -scl appendDiskCacheTimeRange1
- -l1 "Start/End"
- -cc "appendDiskCacheEnabling"
- appendDiskCacheTimeRange4;
-
- floatFieldGrp -nf 2 -label "Start/End" appendDiskCacheStartEndTime;
-
- separator -h 5 -style "none";
-
- radioButtonGrp -nrb 2 -l "Sampling" -l1 "Over" -l2 "Under"
- appendDiskCacheSampling;
-
- intSliderGrp -l "Rate" -min 1 -max 5 -fmn 1 -fmx 100 -value 1
- appendDiskCacheSamplingRate;
-
- setUITemplate -popTemplate;
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -label "Append"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Set the option box title.
- //
- setOptionBoxTitle("Append to Disk Cache Options");
- setOptionBoxCommandName($commandName);
- setOptionBoxHelpTag( "AppendToFluidsCache" );
-
- // Set the current values of the option box.
- //
- eval( $setup + " " + $parent + " " + 0 );
-
- // Show the option box.
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd()
- {
- setOptionVars(false);
-
- string $cmd = "doAppendDiskCache 1 { " +
- "\"" + `optionVar -query appendDiskCacheTimeRange` + "\"" +
- ",\"" + `optionVar -query appendDiskCacheStartTime` + "\"" +
- ",\"" + `optionVar -query appendDiskCacheEndTime` + "\"" +
- ",\"" + `optionVar -query appendDiskCacheSampling` + "\"" +
- ",\"" + `optionVar -query appendDiskCacheSamplingRate` + "\"" +
- " };";
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performAppendDiskCache
- //
- // Description:
- // Perform the command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
- global proc string performAppendDiskCache(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command from option settings.
- //
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
-
- // Show the option box.
- //
- case 1:
- appendDiskCacheOptions();
- break;
-
- // Return the command string.
- //
- case 2:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-